#!/usr/bin/env python
import rospy
from sensor_msgs.msg import JointState
import random

def publish_initial_joint_states():
    rospy.init_node('initial_joint_state_publisher', anonymous=True)
    pub = rospy.Publisher('initial_joint_states', JointState, queue_size=10)
    rospy.sleep(0.5)  # wait for publisher to register

    joint_names = ['joint1', 'joint2', 'joint3', 'joint4', 'joint5', 'joint6', 'joint7']
    joint_positions = [random.uniform(-3.14, 3.14) for _ in range(7)]

    joint_state = JointState()
    joint_state.header.stamp = rospy.Time.now()
    joint_state.name = joint_names
    joint_state.position = joint_positions

    pub.publish(joint_state)
    rospy.loginfo("Published initial joint states: " + str(joint_positions))

if __name__ == '__main__':
    try:
        publish_initial_joint_states()
    except rospy.ROSInterruptException:
        pass
